package com.onepiece.shipelves.common.ticker;

/**
 * 交易所计价模型
 *
 * @author guoyanjiang
 * @date 2019-03-31
 */
public class ExchangeCurrency {

    private final String exchangeKey;

    private final String currencyUnit;

    public ExchangeCurrency(String exchangeKey, String currencyUnit) {
        this.exchangeKey = exchangeKey;
        this.currencyUnit = currencyUnit;
    }

    public String getExchangeKey() {
        return exchangeKey;
    }

    public String getCurrencyUnit() {
        return currencyUnit;
    }

    @Override
    public int hashCode() {
        int hashCode = 17;
        hashCode = hashCode * 31 + exchangeKey.hashCode();
        hashCode = hashCode * 31 + currencyUnit.hashCode();
        return hashCode;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj != null && obj instanceof ExchangeCurrency) {
            ExchangeCurrency target = (ExchangeCurrency) obj;
            return exchangeKey.equals(target.getExchangeKey()) && currencyUnit.equals(target.getCurrencyUnit());
        }
        return false;
    }

    public String provideKey() {
        return String.format("%s_%s", exchangeKey, currencyUnit);
    }
}
